package com.qs.mapper;

import com.qs.pojo.entity.Goods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 商品表 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2023-11-14
 */
@Mapper
public interface GoodsMapper extends BaseMapper<Goods> {

    /**
     * 验证库存
     * @param goodsId
     * @param numbers
     * @return
     */
    Goods checkStock(@Param("goodsId") Integer goodsId,@Param("numbers") Integer numbers);

    /**
     * 锁定库存
     * @param goodsId
     * @param numbers
     * @return
     */
    Integer lockStock(@Param("goodsId") Integer goodsId,@Param("numbers") Integer numbers);

    /**
     * 解锁库存
     * @param goodsId
     * @param numbers
     */
    void unLockStock(@Param("goodsId") Integer goodsId,@Param("numbers") Integer numbers);

    /**
     * 获取昨日上架的新增商品总数
     * @return
     */
    Long findStoreYesterday();

    /**
     * 获取商铺的总销量
     * @param storeIds
     * @return
     */
    Long findPineLineTotal(List<Integer> storeIds);

    /**
     * 获取商铺昨天的销量
     * @param storeIds
     * @return
     */
    Long findPineLineTotalYesterday(List<Integer> storeIds);
}
